<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/7/23
 * Time: 11:21
 */

namespace app\admin\controller;

use think\Db;

class Getmoney extends Base
{
    /**
     * 首页展示
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(request()->isAjax()){
            $user_name = input('user_name');
            $order_type = input('order_type');
            $where = [];
            $where['order_cate'] = 2; // 提现
            //用户名称
            if(isset($user_name) && $user_name != ''){
                $where['user_username'] = ['like', '%' . $user_name . '%'];
            }
            //方式
            if(isset($order_type) && $order_type != ''){
                $where['order_type'] = $order_type;
            }
            $Nowpage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            // 获取总条数
            $count = Db::name('order')
                ->join('up_u_user', 'user_id = order_user_id', 'left')
                ->where($where)
                ->count();
            $lists = Db::name('order')
                ->join('up_u_user', 'user_id = order_user_id', 'left')
                ->field('order_id, order_type, user_username, order_user_id, order_money, 
                user_phone, order_pay_time')
                ->where($where)
                ->page($Nowpage,$limits)
                ->order('order_pay_time desc')
                ->select();
            return json(['code' => 220, 'msg' => '', 'count' => $count, 'data' => $lists]);
        }
        return $this->fetch();
    }
}